package cn.itsource.org.domain;

import cn.itsource.basic.domain.BaseDomain;
import cn.itsource.basic.domain.BaseTreeNode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.annotation.Generated;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

@Data //生成get set hashcode toString
@AllArgsConstructor //全参数构造
@NoArgsConstructor //无参构造
@Table(name="t_department")
@Api("部门对象")
public class Department extends BaseTreeNode<Department> {

    //部门编号
    @ApiModelProperty("部门编号")
    @NotBlank(message = "请输入部门编号")
    @Size(min = 3,max = 6,message = "请输入3-6位的编号")
    private String sn;

    //部门名称
    @ApiModelProperty("部门名称")
    @NotBlank(message = "请输入部门名称")
    private String name;

    //部门状态 1:启用 0:禁用
    @ApiModelProperty("部门状态 1:启用 0:禁用")
    private Integer state;

    //部门经理id
    @ApiModelProperty("部门经理id")
    @Column(name="manager_id")
    private Long managerId;

    //父部门id
    @ApiModelProperty("父部门id")
    @Column(name="parent_id")
    private Long parentId;

    //维护部门路径,先不管
    @Column(name="dir_path")
    private String dirPath;

    @Transient //临时，简单理解就是这个字段不参与数据库的crud
    private String managerName;

    @Transient
    private String parentName;

    @Transient
    private Long[] parentIds;

}
